//
//  MyBindingPhoneViewController.swift
//  YLH
//
//  Created by qinjiangtao on 2024/1/11.
//

import UIKit

class MyBindingPhoneViewController: QIBaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "绑定手机号"
        
        addUI()
    }
    

    
    private func addUI() {
        
        let imgView = UIImageView().then {
            $0.frame = CGRect(x: SCREEN_WIDTH / 2 - 39, y: NAV_HEIGHT + 35, width: 78, height: 78)
            $0.image = UIImage(named: "绑定手机号")
            $0.contentMode = .scaleAspectFill
            $0.clipsToBounds = true
        }
        view.addSubview(imgView)
        
        let phoneL = UILabel().then({
            $0.frame = CGRect(x: 0, y: imgView.bottom + 23, width: SCREEN_WIDTH, height: 20)
            $0.text = "您已绑定手机号\(QIUserModel.shared().mobile)"
            $0.textColor = Color333333
            $0.textAlignment = .center
            $0.font = SYSFONT(ofSize: 14)
        })
        view.addSubview(phoneL)
        
        let title1L = UILabel().then({
            $0.frame = CGRect(x: 0, y: phoneL.bottom, width: SCREEN_WIDTH, height: 20)
            $0.text = "点击下方换绑按钮可更换绑定手机号；"
            $0.textColor = Color333333
            $0.textAlignment = .center
            $0.font = SYSFONT(ofSize: 14)
        })
        view.addSubview(title1L)
        
        let titleStr = """
        注：
        1.无法解绑手机号；手机号一旦换绑，则所关联的实名认证手机号、提现手机号将同步更换为新手机号。
        2.若您的帐号使用手机号登录，换绑后，将使用新号码作为登录手机号。
        """
        let title3L = YYLabel().then({
            $0.frame = CGRect(x: 24, y: title1L.bottom + 30, width: SCREEN_WIDTH - 48, height: 120)
            $0.text = titleStr
            $0.numberOfLines = 0
            $0.textColor = Color999999
            $0.textVerticalAlignment = .top
            $0.font = SYSFONT(ofSize: 14)
        })
        view.addSubview(title3L)
        let att = NSMutableAttributedString(string: titleStr)
        att.yy_lineSpacing = 8
        att.yy_font = SYSFONT(ofSize: 14)
        att.yy_color = Color999999
        title3L.attributedText = att
        
        let replaceBtn = UIButton().then {
            $0.frame = CGRect(x: 16, y: title3L.bottom + 40, width: SCREEN_WIDTH - 32, height: 44)
            $0.backgroundColor = MainColor
            $0.titleLabel?.font = SYSFONT(ofSize: 14)
            $0.setTitle("换绑", for: .normal)
            $0.setTitleColor(.white, for: .normal)
            $0.addRoundedCorners(withRadius: 22)
            $0.addTarget(self, action: #selector(replaceBtnClick), for: .touchUpInside)
        }
        view.addSubview(replaceBtn)
    }
    
    @objc private func replaceBtnClick() {
        let ctl = IDVerificationViewController()
        ctl.isVerification = false
        navigationController?.pushViewController(ctl, animated: true)
    }

}
